<template>
  <div class="app-container">

    <el-card class="box-card">
      <el-form  :rules="rules"  ref="ruleForm" :model="ruleForm"  label-width="150px" v-loading='loading' >
        

        <el-form-item label="通知内容：" prop="hyxxkj_scroll_bar">
          <el-input v-model="ruleForm.hyxxkj_scroll_bar" />
        </el-form-item>


        <el-form-item>
            <el-button @click="handleCancel">取消</el-button>
            <el-button :loading='loading' type="primary" @click="handlePublish">保存</el-button>
        </el-form-item>

      </el-form>
    </el-card>

  </div>
</template>



<script>
import api from '@/api/version/Notice'



export default {
  name: 'noticeEdit',
  data() {
    return {
        loading:false,
        ruleForm: {
          hyxxkj_scroll_bar:'',
        },
       rules:{
          hyxxkj_scroll_bar: [{ required: true, message: '请输入通知内容', trigger: 'blur' }],
       },

    }
  },
  computed: {

  },
  created() {
   
  },
  mounted() {
    this.init()
  },
  methods: {
  
  init(){
        if (this.$route.query.id == null) {
          return
        }
        console.log(this.$route.query.id)
        this.ruleForm.hyxxkj_scroll_bar=this.$route.query.id
      },

    handleCancel: function() {
      this.$store.dispatch('tagsView/delView', this.$route)
      this.$router.push({ path: '../notice/list' })
    },
    handlePublish() {

       this.$refs["ruleForm"].validate((valid) => {
          if (valid) {
              this.update(this.ruleForm)
          } else {
            this.$message({
              message: '请检查数据必填项',
              type: 'warning'
            });
            return false
          }
        })
    },

  update(e) {
      this.loading = true
      api.update(e).then(res => {
          if(res.data.errno==0){
            this.loading = false
            this.$message({
            message: '修改成功',
            type: 'success'
          });
             this.$router.push({ path: '../notice/list' })
          }
      }).catch((e) => {
        this.loading = false
        this.$message({
              message: e.data,
              type: 'warning'
            });
      })
    },

  }
}
</script>
<style lang="scss" scoped>


  
</style>